//
// Created by tang on 2022/1/11.
//

#ifndef DIARYTOOL_APP_HOST_AREA_HPP
#define DIARYTOOL_APP_HOST_AREA_HPP

#include "gui/ui_component.hpp"
#include "app/app_base.hpp"
#include <string>
#include <vector>

class AppHostArea final {

    // Tab data
    struct TabData {
        std::string_view title;
        ComponentPtr view;
    };

    // Dialog data
    struct DialogState {
        std::string_view name;
        unsigned int id;
        ComponentPtr view;
        bool modal;
    };

    std::vector<ComponentPtr> m_all_components_;
    std::list<ComponentPtr> m_menus_;
    std::list<TabData> m_tabs_;
    std::list<DialogState> m_dialogs_;

    uint32_t m_msg_dlg_id_;
    bool     m_progress_show_;
    uint32_t m_msg_type_;
    std::string m_message_;
    std::string m_next_select_tab_;
    Listener m_listener_;
public:
    AppHostArea();
    ~AppHostArea();

    void RegisterComponent(const ComponentPtr& view);
    void OnInit();
    void OnCleanup();

    void ShowPopup(const std::string& id);
    void RenderComponent();
};

#endif //DIARYTOOL_APP_HOST_AREA_HPP
